<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <link rel="icon" href="/favicon.ico" />
  <meta name="title" content="Vue3 vant Admin">
  <meta name="description" content="基于vite和vant和typescript的系统">
  <meta name="keywords" content="vite,vuejs3,vant,typescript,vue-next">
  <meta name="baidu-site-verification" content="code-jvGVv9Wfi7" />
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no" name="viewport" id="viewportMeta">
  <title></title>
</head>

<body>
  <div id="app"></div>
  <script type="module" src="/src/main.ts"></script>
  <!-- <script src="https://xflowcore.zhongan.com/sdk/dist/js/v0.0.1/ilog.js?setting=true"></script> -->
  <!-- <script src="/src/assets/js/ilog.js"></script> -->
  <script>
    // 埋点事件请求路径，针对不同环境需要对应切换(注意切换整体)
      // const url = 'http://172.20.44.7:8080'      // 开发    
      // const url = 'https://utptest.cbit.com.cn/point'   // 测试    
      // const url = 'https://utp.cbit.com.cn/point'      // 生产
      // window['_XFLOW_'] = new XFlow({
      //     siteId:'w8rhjywzmfoqi8rd',// 站点id
      //     method:'post',
      //     history:true,
      //     ignoreClick:true,
      //     maxStringLength:10000000,
      //     serverUrl:url + '/cloud_web_sdk.gif',
      //   })
        
    const setRem = () => {
      // 320 默认大小16px; 320px = 20rem ;每个元素px基础上/16
      let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
      let htmlHeight = document.documentElement.clientHeight || document.body.clientHeight;
      //得到html的Dom元素
      let htmlDom = document.getElementsByTagName('html')[0];
      //设置根元素字体大小
      let change = 1
      if (htmlHeight <htmlWidth &&  htmlHeight/ htmlWidth > 0.8) {
        change = 0.7
      } else if (htmlWidth < htmlHeight && htmlWidth / htmlHeight > 0.8) {
        change = 0.7
      }
      let min = htmlHeight > htmlWidth ? htmlWidth * change : htmlHeight * change;

      htmlDom.style.fontSize = ((min - 375) / 3 + 375) / 23.4375 + 'px';
      // htmlDom.style.fontSize= htmlWidth/23.4375 + 'px';
    }
    setRem();
    // 改变窗口大小时重新设置 rem
    window.onresize = function () {
      setRem()
    }

    // var initViewport = function (height) {
    //     var metaEl = document.querySelector("#viewportMeta");
    //     var content = "width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0,height=" + height;
    //     metaEl.setAttribute('name', 'viewport');
    //     metaEl.setAttribute('content', content);
    //   }
    //   initViewport(window.innerHeight);
    window.deviceUtils = {};
    //设备操作
    (function (utils) {
      utils.log = function (str) {
        console.info(str);
      };
      //获取平台标志
      utils.platfrom = {
        Android: (function () {
          return navigator.userAgent.match(/Android/i) ? true : false;
        })(),
        iOS: (function () {
          return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
        })(),
      };

      var setupWebViewJavascriptBridge = function (callback) {
        if (window.WebViewJavascriptBridge) {
          return callback(WebViewJavascriptBridge);
        }
        if (window.WVJBCallbacks) {
          return window.WVJBCallbacks.push(callback);
        }
        window.WVJBCallbacks = [callback];
        var WVJBIframe = document.createElement("iframe");
        WVJBIframe.style.display = "none";
        // if(getQueryVariable('source') == "CBIT" || getQueryVariable('channel') == "W"){
        //   WVJBIframe.src = ''
        // }else{
        //   WVJBIframe.src = "wvjbscheme://__BRIDGE_LOADED__";
        // }
        WVJBIframe.src = "wvjbscheme://__BRIDGE_LOADED__";
        document.documentElement.appendChild(WVJBIframe);
        setTimeout(function () {
          document.documentElement.removeChild(WVJBIframe);
        }, 0);
      };

    

      //JS调壳
      var callDevice = function (params, funName, callback) {
        try {
          var _bindBridge_device = function (bridge) {
            bridge.callHandler(funName, params, function responseCallback(responseData) {
              // console.log('JS received response:' + responseData);
              callback && callback(responseData);
            });
          };
          setupWebViewJavascriptBridge(_bindBridge_device);
        } catch (err) {
          // console.log('调设备方法发生异常错误(callDevice)：' + err.toString());
        }
      };
    
    
      
      utils.downloadQR=function(url, fileName, callBack = () => { }) {
        const params = {
          downLodURL:url,
          pdfName:fileName
        };
          callDevice(params, 'downloadPdf');
          callBack();
      }

      utils.shareWX = function(title, content,shareUrl,imageUrl, callBack = () => { }){
        console.log(title, content,shareUrl,imageUrl)
        const params = {
          title,
          content,
          shareUrl,
          imageUrl,
        };
      
        callDevice(params, 'shareWX');
        callBack();
      }

      // base64图片分享
      utils.shareWXImage = function(title, content,shareUrl,imageUrl,type,imageSource, callBack = () => { }){
        const params = {
          title,
          content,
          shareUrl,
          imageUrl,
          type,
          imageSource,
        };
      
        callDevice(params, 'shareWXImage');
        callBack();
      }
    

      utils.callDevice = callDevice;

    })(window.deviceUtils);
  </script>
</body>

</html>